Skip to contentSkip to conversation

Change in openvpn[master]: io_work: convert shift argument to uintptr_t

Openvpn-devel ordex (Code Review) 1 participant 4 messages Nov 15, 2023 – Sep 24, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1700055887000.Id5c50dc754837ddb9a9414d8f38982f75e99bace@...2715...

#1 lore raw

Attention is currently required from: flichtenheld, plaisthos.

Hello plaisthos, flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/432?usp=email

to review the following change.

Change subject: io_work: convert shift argument to uintptr_t
......................................................................

io_work: convert shift argument to uintptr_t

Instead of passing the shift argument as pointer, pass directly its integer value. This will allow the code to distinguish a shift value from a real object pointer, like we already do in multi_tcp_process_io().

This change will allow us later to pass an event_arg object as event handler argument instead of a simple integer value.

Change-Id Id5c50dc754837ddb9a9414d8f38982f75e99bace

---
M src/openvpn/forward.c
M src/openvpn/mtcp.c
M src/openvpn/ovpn_dco_linux.h
M src/openvpn/ovpn_dco_win.h

4 files changed, 212 insertions(+), 213 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/32/432/1

src/openvpn/forward.c +9 -11
index 88d3fea..9cc5c6b 100644
@@ -2046,14 +2046,12 @@
     unsigned int tuntap = 0;
     struct event_set_return esr[4];
 
-    /* These shifts all depend on EVENT_READ (=1) and EVENT_WRITE (=2)
-     * and are added to the shift. Check openvpn.h for more details.
-     */
-    static int socket_shift = SOCKET_SHIFT;
-    static int tun_shift = TUN_SHIFT;
-    static int err_shift = ERR_SHIFT;
+    /* These shifts all depend on EVENT_READ and EVENT_WRITE */
+    static uintptr_t socket_shift = 0;   /* depends on SOCKET_READ and SOCKET_WRITE */
+    static uintptr_t tun_shift = 2;      /* depends on TUN_READ and TUN_WRITE */
+    static uintptr_t err_shift = 4;      /* depends on ES_ERROR */
 #ifdef ENABLE_MANAGEMENT
-    static int management_shift = MANAGEMENT_SHIFT;
+    static uintptr_t management_shift = 6; /* depends on MANAGEMENT_READ and MANAGEMENT_WRITE */
 #endif
 #ifdef ENABLE_ASYNC_PUSH
     static int file_shift = FILE_SHIFT;
@@ -2073,7 +2071,7 @@
      */
     if (flags & IOW_WAIT_SIGNAL)
     {
-        wait_signal(c->c2.event_set, (void *)&err_shift);
+        wait_signal(c->c2.event_set, (void *)err_shift);
     }
 
     /*
@@ -2167,7 +2165,7 @@
      * Configure event wait based on socket, tuntap flags.
      */
     socket_set(c->c2.link_socket, c->c2.event_set, socket, (void *)&socket_shift, NULL);
-    tun_set(c->c1.tuntap, c->c2.event_set, tuntap, (void *)&tun_shift, NULL);
+    tun_set(c->c1.tuntap, c->c2.event_set, tuntap, (void *)tun_shift, NULL);
 #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
     if (socket & EVENT_READ && c->c2.did_open_tun)
     {
@@ -2178,7 +2176,7 @@
 #ifdef ENABLE_MANAGEMENT
     if (management)
     {
-        management_socket_set(management, c->c2.event_set, (void *)&management_shift, NULL);
+        management_socket_set(management, c->c2.event_set, (void *)management_shift, NULL);
     }
 #endif
 
@@ -2229,7 +2227,7 @@
                 for (i = 0; i < status; ++i)
                 {
                     const struct event_set_return *e = &esr[i];
-                    c->c2.event_set_status |= ((e->rwflags & 3) << *((int *)e->arg));
+                    c->c2.event_set_status |= ((e->rwflags & 3) << (uintptr_t)e->arg);
                 }
             }
             else if (status == 0)
src/openvpn/mtcp.c +1 -0
index b83bdca..de1d24f 100644
@@ -720,6 +720,7 @@
                         multi_tcp_action(m, mi, TA_SOCKET_READ, false);
                     }
                     break;
+
                 /* new incoming TCP client attempting to connect? */
                 case EVENT_ARG_LINK_SOCKET:
                     ASSERT(m->top.c2.link_socket);
src/openvpn/ovpn_dco_linux.h +157 -157

403 lines not on this page · raw message

src/openvpn/ovpn_dco_win.h +45 -45

128 lines not on this page · raw message

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/432?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id5c50dc754837ddb9a9414d8f38982f75e99bace
Gerrit-Change-Number: 432
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

ordex has abandoned this change. ( http://gerrit.openvpn.net/c/openvpn/+/432?usp=email )

Change subject: io_work: convert shift argument to uintptr_t
......................................................................

Abandoned
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/432?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id5c50dc754837ddb9a9414d8f38982f75e99bace
Gerrit-Change-Number: 432
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: abandon

#3 lore raw
In reply to a message not in the archive

ordex has restored this change. ( http://gerrit.openvpn.net/c/openvpn/+/432?usp=email )

Change subject: io_work: convert shift argument to uintptr_t
......................................................................

Restored
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/432?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id5c50dc754837ddb9a9414d8f38982f75e99bace
Gerrit-Change-Number: 432
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: restore

#4 lore raw
In reply to a message not in the archive

ordex has abandoned this change. ( http://gerrit.openvpn.net/c/openvpn/+/432?usp=email )

Change subject: io_work: convert shift argument to uintptr_t
......................................................................

Abandoned
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/432?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Id5c50dc754837ddb9a9414d8f38982f75e99bace
Gerrit-Change-Number: 432
Gerrit-PatchSet: 1
Gerrit-Owner: ordex <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: abandon